import request from '@/utils/request'
import store from '@/store'
//const ascriptionId = store.state.userInfo.ascriptionId;

// 页面内容 
export function getPage(queryParams) {
    const data = {
      ascriptionId: store.state.userInfo.ascriptionId,
      currentPage: queryParams.currentPage,
      pagesize: queryParams.pagesize
    }
    return request({
      url: '/getBannerPage',
      method: 'post',
      data: data
    })
}

// 数据列表
export function listData(queryParams) {
    const data = {
      ascriptionId: store.state.userInfo.ascriptionId,
      currentPage: queryParams.currentPage,
      pagesize: queryParams.pagesize,
      keywords: queryParams.keywords,  //关键字
      theType: queryParams.theType,  //轮播图类型 1-pc端首页 2-其他
    }
    return request({
      url: '/getBannerList',
      method: 'post',
      data: data
    })
}

// 新增
export function addData(val) {
  const data = {
    projectContent:{
      ascriptionId: store.state.userInfo.ascriptionId, //机构 id
      typeId: val.typeId, //轮播图类型 1-pc端首页 2-其他
      title: val.title, //标题
      thePic: val.thePic, //banner图
      sort: val.sort //位置排序
    }
  }
  return request({
    url: '/addBanner',
    method: 'post',
    data: data
  })
}

// 获取单条数据
export function getData(theid) {
  const data = {
    theid
  }
  return request({
    url: '/getBannerData',
    method: 'post',
    data: data
  })
}

// 修改
export function updateData(val) {
  const data = {
    projectContent:{
      theid: val.theid, //机构 id
      typeId: val.typeId, //轮播图类型 1-pc端首页 2-其他
      title: val.title, //标题
      thePic: val.thePic, //banner图
      sort: val.sort //位置排序
    }
  }
  return request({
    url: '/updateBanner',
    method: 'post',
    data: data
  })
}

// 删除
export function delData(theid) {
  const data = {
    theid
  }
  return request({
    url: '/delBanner',
    method: 'post',
    data: data
  })
}

// 批量删除   idListStr id列表  逗号隔开
export function delMultipleBanner(idListStr) {
  const data = {
    idListStr
  }
  return request({
    url: '/delMultipleLecturer',
    method: 'post',
    data: data
  })
}

// 修改启用状态  enable 启用状态  0-未启用 1-已启用
export function getEnable(theid, enable) {
  const data = {
    projectContent: {
      theid, 
      enable
    }
  }
  return request({
    url: '/changeEnableBanner',
    method: 'post',
    data: data
  })
}